<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" type="text/css" href="/static/lib/datatables/1.10.15/jquery.dataTables.css">
    <div th:include="admin/common :: head"></div>


    <title>审核页面</title>
</head>
<body>

    <input type="hidden" id="id" name="id" th:value="${id}"/>
    <input type="hidden" id="email" name="email" th:value="${email}"/>

    <div class="cl pd-20" style=" background-color:#ffffff">
            <textarea id="brief" name="brief" style="display: none;" >



            </textarea>
    </div>

    <div class="row cl">
        <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">

            <input class="layui-btn" type="submit" id="yes" value="&nbsp;&nbsp;通过&nbsp;&nbsp;">

            <input class="layui-btn layui-btn-danger" id="no" type="submit" value="&nbsp;&nbsp;不通过&nbsp;&nbsp;">

        </div>
    </div>



<footer th:include="admin/common :: footer"></footer>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/static/lib/datatables/1.10.15/jquery.dataTables.js"></script>
<script type="text/javascript" src="/static/lib/laypage/1.2/laypage.js"></script>

<script type="text/javascript" src="/static/lib/myLayui/layui.js"></script>
<link rel="stylesheet" type="text/css" href="/static/lib/myLayui/css/layui.css"/>

<script type="text/javascript">

    var build;
    var layedit;
    layui.use('layedit', function(){
       layedit = layui.layedit;
        build=layedit.build('brief'); //建立编辑器
    });


    $(function() {

        var index = parent.layer.getFrameIndex(window.name);


        $("#yes").click( function () {
            var loadindex=layer.load(3);//打开加载框
            var id=$("#id").val();
            var email=$("#email").val();
            var brief=layedit.getContent(build);

            debugger;
            $.ajax({
                type: "POST",
                url: "/admin/check/doCheckTeacher",
                async : true,
                data: {
                    id:id,
                    email:email,
                    brief:brief,
                    status:1
                },
                success: function(data){
                    if (data.code === 200){
                        parent_reload();//重新加载
                        layer.close(loadindex);//关闭加载框
                        parent.layer.close(index);//关闭弹出层
                        layer.msg('审核通过,邮件已经发送!',{icon:1,time:2000});
                    }else{
                        layer.msg('错误!',{icon:1,time:2000});
                        parent_reload();//重新加载
                        layer.close(loadindex);//关闭加载框
                        parent.layer.close(index);//关闭弹出层
                    }
                },
                error : function(result) {
                    layer.msg("error失败！", {icon: 5, time: 2000});
                    parent_reload();//重新加载
                    layer.close(loadindex);//关闭加载框
                    parent.layer.close(index);//关闭弹出层
                }
            });
        });


        $("#no").click( function () {
            var loadindex=layer.load(3);//打开加载框
            debugger;
            var id=$("#id").val();
            var email=$("#email").val();
            var brief=$("#brief").val();
            $.ajax({
                type: "POST",
                url: "/admin/check/doCheckTeacher",
                async : true,
                data: {
                    id:id,
                    email:email,
                    brief:brief,
                    status:2
                },
                success: function(data){
                    if (data.code === 200){
                        parent_reload();//重新加载
                        layer.close(loadindex);//关闭加载框
                        parent.layer.close(index);//关闭弹出层
                        layer.msg('审核不通过,邮件已经发送!',{icon:1,time:2000});
                    }else{
                        parent_reload();//重新加载
                        layer.close(loadindex);//关闭加载框
                        parent.layer.close(index);//关闭弹出层
                        layer.msg('错误!',{icon:1,time:2000});
                    }
                },
                error : function(result) {
                    parent_reload();//重新加载
                    layer.close(loadindex);//关闭加载框
                    parent.layer.close(index);//关闭弹出层
                    layer.msg("error失败！", {icon: 5, time: 2000});

                }
            });

        });

    })



</script>
</body>
</html>